//
//  YSBookSummaryModel.m
//  YSBookRead
//
//  Created by MOLBASE on 2018/11/12.
//  Copyright © 2018年 YangShen. All rights reserved.
//

#import "YSBookSummaryModel.h"

@implementation YSBookSummaryModel

- (void)encodeWithCoder:(NSCoder *)aCoder {
    [aCoder encodeObject:self.ID forKey:@"ID"];
    [aCoder encodeObject:self.host forKey:@"host"];
    [aCoder encodeObject:self.link forKey:@"link"];
    [aCoder encodeObject:self.source forKey:@"source"];
    [aCoder encodeObject:self.name forKey:@"name"];
    [aCoder encodeInteger:self.chaptersCount forKey:@"chaptersCount"];
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super init]) {
        self.ID     = [aDecoder decodeObjectForKey:@"ID"];
        self.host   = [aDecoder decodeObjectForKey:@"host"];
        self.link   = [aDecoder decodeObjectForKey:@"link"];
        self.name   = [aDecoder decodeObjectForKey:@"name"];
        self.source = [aDecoder decodeObjectForKey:@"source"];
        self.chaptersCount = [aDecoder decodeIntegerForKey:@"chaptersCount"];
    }
    return self;
}

- (instancetype)initWithDict:(NSDictionary *)dict {
    if (self = [super init]) {
        _ID     = [NSString stringWithFormat:@"%@", dict[@"_id"]];
        _host   = [NSString stringWithFormat:@"%@", dict[@"host"]];
        _link   = [NSString stringWithFormat:@"%@", dict[@"link"]];
        _name   = [NSString stringWithFormat:@"%@", dict[@"name"]];
        _source = [NSString stringWithFormat:@"%@", dict[@"source"]];
        _chaptersCount = [[NSString stringWithFormat:@"%@", dict[@"chaptersCount"]] integerValue];
    }
    return self;
}

@end
